home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / pdsrt211.arc / PDSORT.DOC < prev    next >
Text File  |  1990-06-18  |  15KB  |  306 lines

  1.                                    PDSORT
  2.                    A Public Domain External Sort Program
  3.  
  4. Author:   Don A. Williams
  5. Version:  2.0.0
  6. Date:     May 18, 1990
  7.  
  8.    ****************************  NOTICE!  **************************
  9.    *   Contrary to the current trend  in  MS-DOS  software  this   *
  10.    *   program,  for  whatever  it is worth,  is NOT copyrighted   *
  11.    *   (with the exception of the runtime library  from  Borland   *
  12.    *   International's  Turbo  C)!  The program,  in whole or in   *
  13.    *   part,  may be used freely in any fashion  or  environment   *
  14.    *   desired.  If  you  find this program to be useful to you,   *
  15.    *   do NOT send any contribution to the author;  in the words   *
  16.    *   of  Rick  Conn,   'Enjoy!'  However,   if  you  make  any   *
  17.    *   improvements,  I would enjoy  receiving  a  copy  of  the   *
  18.    *   modified  source.  I  can  be reached,  usually within 24   *
  19.    *   hours,  by  messages  on  any  of  the  Phoenix  systems,   *
  20.    *   particularly:                                               *
  21.    *                                                               *
  22.    *               The Tool Shop BBS       [PCBOARD]               *
  23.    *                   (602) 279-2673   1200/2400/9600 bps         *
  24.    *                   (Good luck trying!  VERY BUSY!)             *
  25.    *               Technoids Anonymous     [PCBOARD]               *
  26.    *                   (602) 899-4876   300/1200/2400 bps          *
  27.    *                                                               *
  28.    *   All can be reached through PC Pursuit.                      *
  29.    *                                                               *
  30.    *   or:                                                         *
  31.    *                on GEnie, mail address: DON-WILL               *
  32.    *                on CompuServ:           75410,543              *
  33.    *                                                               *
  34.    *   Every  effort has been made to avoid error and moderately   *
  35.    *   extensive testing has been  performed  on  this  program,   *
  36.    *   however, the author does not warrant it to be fit for any   *
  37.    *   purpose  or  to  be  free  from  error  and disclaims any   *
  38.    *   liability for actual or any other damage arising from the   *
  39.    *   use of this program.                                        *
  40.    *****************************************************************
  41.  
  42. PDSORT is a fully public domain external sort  program,  i.e.  it  can 
  43. sort  files  that  are  too big to be wholly contained in memory.  The 
  44. length of the file that can be sorted by PDSORT is limited only by the 
  45. available disk space,  however,  you must have at least twice as  much 
  46. free  space  as  the  length of the file to be sorted - PDSORT uses an 
  47. intermediate file the size of the input file  and  the  sorted  output 
  48. file will be the same size as the input file.  
  49.  
  50.  
  51. USAGE: 
  52.  
  53. There are two forms for executing PDSORT: 
  54.  
  55.     pdsort in_file out_file [option] max_record_length [key_spec ....]
  56.  
  57. and:
  58.  
  59.     pdsort - [option] max_record_length [key_spec ....] <in_file >out_file
  60.  
  61. In the first form,  the input_file specification can be  any  standard 
  62. MS-DOS  file  specification including full path specifications but may 
  63. NOT contain "wild cards".  The output_file specification may  also  be 
  64. any  standard  MS-DOS  file specification not containing "wild cards".  
  65. The input_file and output_file names may be  the  same  but,  in  this 
  66. case,  the  input_file  will  be destroyed by PDSORT by overwriting it 
  67. with the input file.  The max_record_length argument is  required  and 
  68. no  records  in  the input file may exceed this value.  If a record is 
  69. detected in the input file that exceeds the specified  maximum  record 
  70. length,  PDSORT  will  issue a message identifying the record and will 
  71. terminate.  
  72.  
  73. In the second form, PDSORT executes as a "filter", reading and sorting 
  74. standard input to produce  standard  output,  both  of  which  may  ne 
  75. redirected.  
  76.  
  77.  
  78. Options:
  79.  
  80. The only options supported by version 2.0.0 of PDSORT are: 
  81.  
  82.     -······A single '-',  delimited by  blanks,  instructs  PDSORT  to 
  83.            operate  as a filter,  taking its input from standard input 
  84.            and sending its output to standard output.  
  85.  
  86.     -tpath·The '-t option allows the user to specify the path for  the 
  87.            intermediate  file  created  by PDSORT.  If no such path is 
  88.            specified,  PDSORT will use the path of the output file as 
  89.            the  path of the intermediate file.  If the "filter" option 
  90.            is selected and no intermediate file path is specified, the 
  91.            intermediate file will be created in the current directory.  
  92.  
  93.  
  94. Key Specification:
  95.  
  96. There  may  be  as  many keys specified as you wish.  The file will be 
  97. sorted on the keys in the order in  which  they  are  specified.  Each 
  98. key_spec has one of the following two formats: 
  99.  
  100.     b:l:[field_options]
  101.  
  102. or:
  103.  
  104.     b-e:[field_options]
  105.  
  106. where:
  107.  
  108.     b·-·Specifies  the  beginning  character  position of the field in 
  109.         decimal;  i.e to sort a field that is in columns 10 through 17 
  110.         of the record, b would be 10.
  111.     l·-·Specifies the length of the field in characters; i.e to sort a 
  112.         field that is in columns 10 through 17 of the record,  l would 
  113.         be 8 - 10:8[:options].
  114.     e·-·Specifies the  ending  character  position  of  the  field  in 
  115.         decimal,  inclusive;  i.e to sort a file that is in characters 
  116.         10 through 17 of the record with  this  format  of  the  field 
  117.         specifier would require the e be 17 - 10-17[:options].
  118.  
  119. Field Options:
  120.  
  121.     a·-·Specifies  that  the  sort on this field is to be in ascending 
  122.         order,  the default if no field option is specified  for  this 
  123.         field.  
  124.  
  125.     d·-·Specifies  that  the sort on this field is to be in descending 
  126.         order.  
  127.  
  128.     c·-·Specifies that the sort on this field is to be case sensitive; 
  129.         i.e.  the  word  Abscess"  would  sort  lower  that  the  word 
  130.         "abscess".  A  case  sensitive  sort  is the default if none 
  131.         is specified.  
  132.  
  133.     i·-·Specifies  that  the  sort  on  this  field  is  to  be   case 
  134.         insensitive.  
  135.  
  136.     c·-·Specifies that this field is ASCII character data, the default 
  137.         if  not  specified.  Since  PDSORT  2.0.0  supports only ASCII 
  138.         character fields, this option if only for upward compatibility 
  139.         with future version of PDSORT that  may  support  other  field 
  140.         types such as integer (numeric).  
  141.  
  142.  
  143.  
  144. Examples:
  145.  
  146. Assume  a  file,  named  FILELIST,  that contains a list of file name, 
  147. sizes, date/times, and paths, such as can be created by NUFIND: 
  148.  
  149.     a----w           27,974 90-04-30  6:30 c:\acelst.430
  150.     a----w           28,196 90-05-21  5:05 c:\acelst.521
  151.     a----w           28,238 90-05-25  5:41 c:\acelst.525
  152.     a----w           26,705 90-05-25  5:39 c:\acelst.lst
  153.     a----w          128,537 90-05-25  5:41 c:\acelst.zip
  154.     a----w              904 90-05-23  4:33 c:\autoexec.bat
  155.     a----w           35,840 89-06-30 12:16 c:\command.com
  156.     a----w               46 89-08-20  3:53 c:\config.cal
  157.     a----w              284 90-05-21 19:52 c:\config.sys
  158.     a----w            2,128 90-05-23  4:32 c:\configur.dat
  159.     ------           39,385 89-07-14 12:00 c:\drbdos.sys
  160.     ------           18,304 89-06-30 12:16 c:\drbios.sys
  161.     ---sh-            4,096 90-03-18 13:22 c:\drildr.sys
  162.     a----w              167 89-10-11  7:56 c:\dsas.cmd
  163.     a----w              102 86-11-04  9:14 c:\ed.def
  164.     a----w           50,326 86-10-02 21:34 c:\ed.hlp
  165.     a----w            3,362 86-06-09 13:10 c:\fakey.com
  166.     a----w                0 90-05-23  7:54 c:\ftf.dat
  167.     a----w           12,275 85-06-16 18:12 c:\helpe.def
  168.     a----w               79 89-05-17  5:02 c:\indent.pro
  169.     a----w            7,122 90-01-15  1:00 c:\lineend.com
  170.     a----w            1,060 90-05-25  9:40 c:\mark0
  171.     a--sh-               41 90-05-25  9:40 c:\mirorsav.fil
  172.     a-----           41,472 90-05-25  9:40 c:\mirror.bak
  173.     a-----           41,472 90-05-25  9:40 c:\mirror.fil
  174.     a----w              237 90-02-06  5:09 c:\model
  175.     a----w           12,432 87-03-10 13:34 c:\mouse.sys
  176.     a----w            2,507 87-10-21 13:45 c:\nansi.sys
  177.     a----w              251 87-07-16 18:06 c:\newkbios.com
  178.     a----w            6,094 89-11-21 15:03 c:\no101.com
  179.     a----w            2,836 90-05-03  7:21 c:\phone.dir
  180.     a----w            2,670 89-12-01 17:00 c:\phones
  181.     a----w            2,010 90-03-18 11:14 c:\pushdir.stk
  182.     a----w               90 89-09-05  3:29 c:\ruler.def
  183.     a----w            1,465 87-04-22 10:38 c:\ruler.prt
  184.     a----w           53,632 85-05-03 14:09 c:\sk.hlp
  185.     a----w           33,611 86-12-05  9:21 c:\skn.com
  186.     a----w           18,825 90-01-15  1:00 c:\synonym.com
  187.     a----w            1,610 90-05-13 16:15 c:\synonym.def
  188.     a----w           14,426 90-05-19 17:38 c:\utils
  189.     a----w            1,060 90-05-25 12:17 c:\mark1
  190.  
  191. The file path name begins in column 40 and  extends  through  80,  the 
  192. file size is in columns 15 through 23,  inclusive, the file date is in 
  193. columns 25 through 32,  inclusive,  and the file time is in columns 34 
  194. through 39, inclusive.  
  195.  
  196. A PDSORT command sort this list so that the largest files are first 
  197. and files of equal size are in name order would require the following 
  198. command:
  199.  
  200.     pdsort filelist fileout 80 15-23:d 44-80
  201.  
  202. giving the following list in the file FILEOUT:
  203.  
  204.     a----w          128,537 90-05-25  5:41 c:\acelst.zip
  205.     a----w           53,632 85-05-03 14:09 c:\sk.hlp
  206.     a----w           50,326 86-10-02 21:34 c:\ed.hlp
  207.     a-----           41,472 90-05-25  9:40 c:\mirror.bak
  208.     a-----           41,472 90-05-25  9:40 c:\mirror.fil
  209.     ------           39,385 89-07-14 12:00 c:\drbdos.sys
  210.     a----w           35,840 89-06-30 12:16 c:\command.com
  211.     a----w           33,611 86-12-05  9:21 c:\skn.com
  212.     a----w           28,238 90-05-25  5:41 c:\acelst.525
  213.     a----w           28,196 90-05-21  5:05 c:\acelst.521
  214.     a----w           27,974 90-04-30  6:30 c:\acelst.430
  215.     a----w           26,705 90-05-25  5:39 c:\acelst.lst
  216.     a----w           18,825 90-01-15  1:00 c:\synonym.com
  217.     ------           18,304 89-06-30 12:16 c:\drbios.sys
  218.     a----w           14,426 90-05-19 17:38 c:\utils
  219.     a----w           12,432 87-03-10 13:34 c:\mouse.sys
  220.     a----w           12,275 85-06-16 18:12 c:\helpe.def
  221.     a----w            7,122 90-01-15  1:00 c:\lineend.com
  222.     a----w            6,094 89-11-21 15:03 c:\no101.com
  223.     ---sh-            4,096 90-03-18 13:22 c:\drildr.sys
  224.     a----w            3,362 86-06-09 13:10 c:\fakey.com
  225.     a----w            2,836 90-05-03  7:21 c:\phone.dir
  226.     a----w            2,670 89-12-01 17:00 c:\phones
  227.     a----w            2,507 87-10-21 13:45 c:\nansi.sys
  228.     a----w            2,128 90-05-23  4:32 c:\configur.dat
  229.     a----w            2,010 90-03-18 11:14 c:\pushdir.stk
  230.     a----w            1,610 90-05-13 16:15 c:\synonym.def
  231.     a----w            1,465 87-04-22 10:38 c:\ruler.prt
  232.     a----w            1,060 90-05-25  9:40 c:\mark0
  233.     a----w            1,060 90-05-25 12:17 c:\mark1
  234.     a----w              904 90-05-23  4:33 c:\autoexec.bat
  235.     a----w              284 90-05-21 19:52 c:\config.sys
  236.     a----w              251 87-07-16 18:06 c:\newkbios.com
  237.     a----w              237 90-02-06  5:09 c:\model
  238.     a----w              167 89-10-11  7:56 c:\dsas.cmd
  239.     a----w              102 86-11-04  9:14 c:\ed.def
  240.     a----w               90 89-09-05  3:29 c:\ruler.def
  241.     a----w               79 89-05-17  5:02 c:\indent.pro
  242.     a----w               46 89-08-20  3:53 c:\config.cal
  243.     a--sh-               41 90-05-25  9:40 c:\mirorsav.fil
  244.     a----w                0 90-05-23  7:54 c:\ftf.dat
  245.  
  246. The same sort could be accomplished by the command:
  247.  
  248.     pdsort - 80 15-23:d 40-80 <filelist >fileout
  249.  
  250.  
  251. Now suppose that you wanted the most recently modified or  created  files 
  252. first.  The following command would do that:
  253.  
  254.     pdsort filelist fileout 80 25-32:d 34-39:d 40-80
  255.  
  256. giving the following list in FILEOUT:
  257.  
  258.     a----w            1,060 90-05-25 12:17 c:\mark1
  259.     a----w            1,060 90-05-25  9:40 c:\mark0
  260.     a--sh-               41 90-05-25  9:40 c:\mirorsav.fil
  261.     a-----           41,472 90-05-25  9:40 c:\mirror.bak
  262.     a-----           41,472 90-05-25  9:40 c:\mirror.fil
  263.     a----w           28,238 90-05-25  5:41 c:\acelst.525
  264.     a----w          128,537 90-05-25  5:41 c:\acelst.zip
  265.     a----w           26,705 90-05-25  5:39 c:\acelst.lst
  266.     a----w                0 90-05-23  7:54 c:\ftf.dat
  267.     a----w              904 90-05-23  4:33 c:\autoexec.bat
  268.     a----w            2,128 90-05-23  4:32 c:\configur.dat
  269.     a----w              284 90-05-21 19:52 c:\config.sys
  270.     a----w           28,196 90-05-21  5:05 c:\acelst.521
  271.     a----w           14,426 90-05-19 17:38 c:\utils
  272.     a----w            1,610 90-05-13 16:15 c:\synonym.def
  273.     a----w            2,836 90-05-03  7:21 c:\phone.dir
  274.     a----w           27,974 90-04-30  6:30 c:\acelst.430
  275.     ---sh-            4,096 90-03-18 13:22 c:\drildr.sys
  276.     a----w            2,010 90-03-18 11:14 c:\pushdir.stk
  277.     a----w              237 90-02-06  5:09 c:\model
  278.     a----w            7,122 90-01-15  1:00 c:\lineend.com
  279.     a----w           18,825 90-01-15  1:00 c:\synonym.com
  280.     a----w            2,670 89-12-01 17:00 c:\phones
  281.     a----w            6,094 89-11-21 15:03 c:\no101.com
  282.     a----w              167 89-10-11  7:56 c:\dsas.cmd
  283.     a----w               90 89-09-05  3:29 c:\ruler.def
  284.     a----w               46 89-08-20  3:53 c:\config.cal
  285.     ------           39,385 89-07-14 12:00 c:\drbdos.sys
  286.     a----w           35,840 89-06-30 12:16 c:\command.com
  287.     ------           18,304 89-06-30 12:16 c:\drbios.sys
  288.     a----w               79 89-05-17  5:02 c:\indent.pro
  289.     a----w            2,507 87-10-21 13:45 c:\nansi.sys
  290.     a----w              251 87-07-16 18:06 c:\newkbios.com
  291.     a----w            1,465 87-04-22 10:38 c:\ruler.prt
  292.     a----w           12,432 87-03-10 13:34 c:\mouse.sys
  293.     a----w           33,611 86-12-05  9:21 c:\skn.com
  294.     a----w              102 86-11-04  9:14 c:\ed.def
  295.     a----w           50,326 86-10-02 21:34 c:\ed.hlp
  296.     a----w            3,362 86-06-09 13:10 c:\fakey.com
  297.     a----w           12,275 85-06-16 18:12 c:\helpe.def
  298.     a----w           53,632 85-05-03 14:09 c:\sk.hlp
  299.  
  300. Again,  the same sort could have been accomplished  by  the  following 
  301. command: 
  302.  
  303.     pdsort - 25-32:d 34-39:d 40-80 <filelist >fileout
  304.  
  305.  
  306.